package com.online.fund;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class JsoupTest {

	public static void main(String[] args) throws MalformedURLException, IOException {
//		String html = "<html><head><title>First parse</title></head>"
//				+ "<body><p>Parsed HTML into a doc.</p></body></html>";
//		Document doc = Jsoup.parse(html);
//		System.out.println(doc);
//		
//		Document baiduDoc = Jsoup.parse(new URL("http://www.baidu.com"), 1000);
//		System.out.println(baiduDoc);
//		
//		Document bodyDoc = Jsoup.parseBodyFragment(html);
//		Element body = bodyDoc.body();
//		System.out.println(body);
//		
//		Document baiDoc = Jsoup.connect("http://www.baidu.com").get();
//		String title = baiDoc.title();
//		System.out.println(title);
//		
//		Document doc2 = Jsoup.connect("http://www.baidu.com")
//				  .data("query", "Java")
//				  .userAgent("Mozilla")
//				  .cookie("auth", "token")
//				  .timeout(3000)
//				  .post();
//		System.out.println(doc2);
		
		Document metaDoc = Jsoup.connect("http://quote.eastmoney.com/sz000585.html").get();
		if (metaDoc.select("meta[name='mobile-agent']").hasAttr("content")) {
			String content = metaDoc.select("meta[name='mobile-agent']").eachAttr("content").get(0);
			System.out.println(metaDoc.select("meta[name='mobile-agent']").eachAttr("content").get(0));
		}
		
		String content = "format=html5; url=http://m2.quote.eastmoney.com/h5stock/0005852.html";
		System.out.println(content.substring(content.lastIndexOf("/") + 1, content.length() - 5));
		
	}
	

}
